//T10006. 工作分配问题
#include <iostream>
using namespace std;
const int MAXN=20;
int c[MAXN+1][MAXN+1];
int n;
int mincost;
bool flag[MAXN+1];
void search(int cost,int i){
    if (cost>=mincost) return;
    if (i>n) return;
    for(int j=1;j<=n;j++){
        if (!flag[j]){
            cost+=c[i][j];
            flag[j]=true;
            if (i==n&&cost<mincost) mincost=cost;
            else search(cost,i+1);
            cost-=c[i][j];
            flag[j]=false;
        }
    }
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            cin>>c[i][j];
            if (i==j) mincost+=c[i][j];
        }
    search(0,1);
    cout<<mincost;
}